package com.example.tliaswebmanagement.config;

import com.example.tliaswebmanagement.interceptor.DemoInterceptor;
import com.example.tliaswebmanagement.interceptor.TokenInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器（配置类）
 * 基于 拦截器实现令牌校验
 */
@Slf4j
@Configuration  // 代表这个类是配置类
public class WebConfig implements WebMvcConfigurer {

//    private final DemoInterceptor demoInterceptor;
//    public WebConfig(DemoInterceptor demoInterceptor) {
//        this.demoInterceptor = demoInterceptor;
//    }
//    private final TokenInterceptor interceptor;
//
//    public WebConfig(TokenInterceptor interceptor) {
//        this.interceptor = interceptor;
//    }
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(interceptor).addPathPatterns("/**")   // 拦截所有请求
//                .excludePathPatterns("/login");     // 不拦截登陆请求
//    }
}
